using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using SFS.SampleApp.Web.Mvc.Resources;
using System.Runtime.Serialization;
using SFSdotNet.Framework.Web.Mvc.Models;
using SFSdotNet.Framework.Web.Mvc.Extensions;
using BO = SFS.SampleApp.BusinessObjects;
using System.Web.Mvc;
using SFSdotNet.Framework.Web.Mvc.Validation;
using SFSdotNet.Framework.Web.Mvc.Models;
using SFSdotNet.Framework.Web.Mvc.Resources;
using SFSdotNet.Framework.Entities.Metadata;


namespace SFS.SampleApp.Web.Mvc.Models.ProductDescriptions 
{
	public partial class ProductDescriptionModel: ModelBase{
		public ProductDescriptionModel()
        {
		}
		public override string Id
        {
            get
            {
                return this.ProductDescriptionID.ToString();
            }
        }
			
			
        public override string ToString()
        {
		
            return this.Description.ToString();
		
        }    
			
	
		[SystemProperty()]		
		public Int32? ProductDescriptionID{ get; set; }
		
	
[Exportable()]
	
	    [Required(AllowEmptyStrings=false, ErrorMessageResourceName="VAL_DESCRIPTION_REQUIRED", ErrorMessageResourceType=typeof(ProductDescriptionResources))]
		
	[RelationFilterable()]
	[LocalizedDisplayName("DESCRIPTION", NameResourceType=typeof(ProductDescriptionResources))]
	public String   Description { get; set; }
		
		
	
[Exportable()]
		
	[RelationFilterable()]
	[SystemProperty()]
	[LocalizedDisplayName("ROWGUID", NameResourceType=typeof(ProductDescriptionResources))]
	public Guid   rowguid { get; set; }
		
		
	
[Exportable()]
	
	    [Required(AllowEmptyStrings=false, ErrorMessageResourceName="VAL_MODIFIEDDATE_REQUIRED", ErrorMessageResourceType=typeof(ProductDescriptionResources))]
		
	[RelationFilterable()]
	[DateTime(true, false, null)]	
	[LocalizedDisplayName("MODIFIEDDATE", NameResourceType=typeof(ProductDescriptionResources))]
	public DateTime   ModifiedDate { get; set; }
	public string ModifiedDateText {
        get {
            if (ModifiedDate != null)
			
                return ((DateTime)ModifiedDate).ToShortDateString();
            else
                return String.Empty;
        }
				set{
				this.ModifiedDate = Convert.ToDateTime(value);
    }
		}
		
		
		
		[LocalizedDisplayName("PRODUCTMODELPRODUCTDESCRIPTIONS", NameResourceType=typeof(ProductDescriptionResources))]
		[RelationFilterable(IsNavigationPropertyMany=true, FiltrablePropertyPathName="ProductModelProductDescriptions.Count()", ModelPartialType="ProductModelProductDescriptions.ProductModelProductDescription")]
        public List<ProductModelProductDescriptions.ProductModelProductDescriptionModel> ProductModelProductDescriptions { get; set; }			
	
	public override string SafeKey
   	{
		get
        {
			if(this.ProductDescriptionID != null)
				return SFSdotNet.Framework.Entities.Utils.GetKey(this ,"ProductDescriptionID").Replace("/","-");
			else
				return String.Empty;
		}
    }		
		public void Bind(ProductDescriptionModel model){
            
		this.ProductDescriptionID = model.ProductDescriptionID;
		this.Description = model.Description;
		this.rowguid = model.rowguid;
		this.ModifiedDate = model.ModifiedDate;
        }

        public BusinessObjects.ProductDescription GetBusinessObject()
        {
            BusinessObjects.ProductDescription result = new BusinessObjects.ProductDescription();
	if (this.ProductDescriptionID != null )
				result.ProductDescriptionID = (Int32)this.ProductDescriptionID;
				
	if (this.Description != null )
				result.Description = (String)this.Description.Trim().Replace("\t", String.Empty);
				
	if (this.rowguid != null )
				result.rowguid = (Guid)this.rowguid;
				
				result.ModifiedDate = (DateTime)this.ModifiedDate;		
				



            return result;
        }
        public void Bind(BusinessObjects.ProductDescription businessObject)
        {
            
			this.ProductDescriptionID = businessObject.ProductDescriptionID;
				
			this.Description = businessObject.Description != null ? businessObject.Description.Trim().Replace("\t", String.Empty) : "";
				
			this.rowguid = businessObject.rowguid;
				
				this.ModifiedDate = (DateTime)businessObject.ModifiedDate;
           
        }
	}
}
